from utlis.mysql import db
from myredis import r
# 审核接口
import time
import tornado.web
import tornado.ioloop
import asyncio
async def Setarge(i):
    while True:
        await asyncio.sleep(2)
        biaodi = r.list_pop("weishenhe")
        print(11111,biaodi)
        if biaodi:
            number = hash(int(biaodi.decode())) % 3
            print(number)
            if number == 0:
                sqls = """update landmarks set audit_userid=%d where code=%d""" % (int(i['id']), int(biaodi))
                db.add(sqls)
                db.commit()
                r.list_push("shen",biaodi)
            else:
                sqls = """update landmarks%d set audit_userid=%d where code=%d""" % (
                    int(number), int(i['id']), int(biaodi))
                db.add(sqls)
                r.list_push("shen", biaodi)
                db.commit()
        print('程序运行中')
sql = """select id from admin_user where roleid=1"""
res = db.findAll(sql)
loop = asyncio.get_event_loop()
# 生成任务
tasks = [Setarge(i) for i in res]
# wait加入任务
taskwait = asyncio.wait(tasks)
# 启动
loop.run_until_complete(taskwait)

loop.close()
